package com.sprd.simple.model;

import android.content.ContentResolver;
import android.content.Context;
import android.speech.tts.TextToSpeech;
import android.provider.Settings;
import android.util.Log;

import java.util.Locale;

/**
 * Created by SPRD on 16-8-24.
 */
public class TextSpeech {
    private static final String TAG = "TextSpeech";
    private static TextToSpeech textToSpeech;

    public static void read(final String appName, final Context context) {
        textToSpeech = new TextToSpeech(context, new TextToSpeech.OnInitListener() {
            @Override
            public void onInit(int status) {
               /*  try {
                   Log.d(TAG, "mTextToSpeech.speak && VOICE_FOR_MENU = " + (
                            Settings.System.getInt(context.getContentResolver(),
                            Settings.System.VOICE_FOR_MENU)));
                    if ((Settings.System.getInt(context.getContentResolver(),
                            Settings.System.VOICE_FOR_MENU)) == 1) {
                        Log.d(TAG, "onInit()  ");
                        if (status == TextToSpeech.SUCCESS) {
                            Log.d(TAG, "TextToSpeech.SUCCESS");
                            textToSpeech.speak(appName,
                                    TextToSpeech.QUEUE_FLUSH, null);
                            Log.d(TAG, "app name = " + appName);
                        } else {
                            Log.d(TAG, "Could not initialize TextToSpeech.");
                        }
                    }
                } catch (Settings.SettingNotFoundException e) {
                    e.printStackTrace();
                }*/
            }
        });
    }

    public static void readNumber(final String number, final Context context) {
        textToSpeech = new TextToSpeech(context, new TextToSpeech.OnInitListener() {
            @Override
            public void onInit(int status) {
                /*try {
                      Log.d(TAG, "mTextToSpeech.speak && VOICE_FOR_CALL = " + (
                          Settings.System.getInt(context.getContentResolver(),
                                    Settings.System.VOICE_FOR_CALL)));
                    if ((Settings.System.getInt(context.getContentResolver(),
                            Settings.System.VOICE_FOR_CALL)) == 1) {
                        if (status == TextToSpeech.SUCCESS) {
                            Log.d(TAG, "TextToSpeech.SUCCESS");
                            textToSpeech.speak(number,
                                    TextToSpeech.QUEUE_FLUSH, null);
                            Log.d(TAG, "number = " + number);
                        } else {
                            Log.d(TAG, "Could not initialize TextToSpeech.");
                        }
                    }
                } catch (Settings.SettingNotFoundException e) {
                    e.printStackTrace();
                }*/
            }
        });
    }
}
